package panels;

import java.awt.Color;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import dane.Towar;
import dane.Zapytania;

/**
 * Klasa ustawiająca sposób wyświetlania listy płyt w komponencie JList
 * @version 1.0 2013
 * @author Dorota Chyła, Tomasz Bednarski, Wojciech Florkowski, Łukasz Gąsiewicz
 */
class DisplayJListTow extends JLabel implements ListCellRenderer {
     final static ImageIcon longIcon = new ImageIcon("/img/yes.png");
     final static ImageIcon shortIcon = new ImageIcon("/img/no.png");

     /**
      * Metoda zdefiniowana przez ListCellRenderer configurująca sposób wyświetlania JList
      */
     public DisplayJListTow getListCellRendererComponent(
       JList list,
       Object value,            // value to display
       int index,               // cell index
       boolean isSelected,      // is the cell selected
       boolean cellHasFocus)    // the list and the cell have the focus
     {
    	 Towar t = (Towar) value;
    	 
    	 setText(t.getNazwaAlbumu());
         
         if (isSelected) {
             setBackground(Color.LIGHT_GRAY);//list.getSelectionBackground()
             setForeground(Color.WHITE);//list.getSelectionForeground()
         }
         else {
        	 setBackground(list.getBackground());
        	 setForeground(list.getForeground());
         }
         setEnabled(list.isEnabled());
         setFont(list.getFont());
         setOpaque(true);
         return this;
     }
 }